# SPDX-FileCopyrightText: 2023 CitruS Emulator Project
# SPDX-License-Identifier: GPL-3.0-or-later

add_library(oboe STATIC
    oboe/aaudio/AAudioLoader.cpp
    oboe/aaudio/AudioStreamAAudio.cpp
    oboe/common/AdpfWrapper.cpp
    oboe/common/AudioSourceCaller.cpp
    oboe/common/AudioStream.cpp
    oboe/common/AudioStreamBuilder.cpp
    oboe/common/DataConversionFlowGraph.cpp
    oboe/common/FilterAudioStream.cpp
    oboe/common/FixedBlockAdapter.cpp
    oboe/common/FixedBlockReader.cpp
    oboe/common/FixedBlockWriter.cpp
    oboe/common/LatencyTuner.cpp
    oboe/common/OboeExtensions.cpp
    oboe/common/SourceFloatCaller.cpp
    oboe/common/SourceI16Caller.cpp
    oboe/common/SourceI24Caller.cpp
    oboe/common/SourceI32Caller.cpp
    oboe/common/Utilities.cpp
    oboe/common/QuirksManager.cpp
    oboe/fifo/FifoBuffer.cpp
    oboe/fifo/FifoController.cpp
    oboe/fifo/FifoControllerBase.cpp
    oboe/fifo/FifoControllerIndirect.cpp
    oboe/flowgraph/FlowGraphNode.cpp
    oboe/flowgraph/ChannelCountConverter.cpp
    oboe/flowgraph/ClipToRange.cpp
    oboe/flowgraph/Limiter.cpp
    oboe/flowgraph/ManyToMultiConverter.cpp
    oboe/flowgraph/MonoBlend.cpp
    oboe/flowgraph/MonoToMultiConverter.cpp
    oboe/flowgraph/MultiToManyConverter.cpp
    oboe/flowgraph/MultiToMonoConverter.cpp
    oboe/flowgraph/RampLinear.cpp
    oboe/flowgraph/SampleRateConverter.cpp
    oboe/flowgraph/SinkFloat.cpp
    oboe/flowgraph/SinkI16.cpp
    oboe/flowgraph/SinkI24.cpp
    oboe/flowgraph/SinkI32.cpp
    oboe/flowgraph/SinkI8_24.cpp
    oboe/flowgraph/SourceFloat.cpp
    oboe/flowgraph/SourceI16.cpp
    oboe/flowgraph/SourceI24.cpp
    oboe/flowgraph/SourceI32.cpp
    oboe/flowgraph/SourceI8_24.cpp
    oboe/flowgraph/resampler/IntegerRatio.cpp
    oboe/flowgraph/resampler/LinearResampler.cpp
    oboe/flowgraph/resampler/MultiChannelResampler.cpp
    oboe/flowgraph/resampler/PolyphaseResampler.cpp
    oboe/flowgraph/resampler/PolyphaseResamplerMono.cpp
    oboe/flowgraph/resampler/PolyphaseResamplerStereo.cpp
    oboe/flowgraph/resampler/SincResampler.cpp
    oboe/flowgraph/resampler/SincResamplerStereo.cpp
    oboe/opensles/AudioInputStreamOpenSLES.cpp
    oboe/opensles/AudioOutputStreamOpenSLES.cpp
    oboe/opensles/AudioStreamBuffered.cpp
    oboe/opensles/AudioStreamOpenSLES.cpp
    oboe/opensles/EngineOpenSLES.cpp
    oboe/opensles/OpenSLESUtilities.cpp
    oboe/opensles/OutputMixerOpenSLES.cpp
    oboe/common/StabilizedCallback.cpp
    oboe/common/Trace.cpp
    oboe/common/Version.cpp
)

target_compile_options(oboe PRIVATE -Wno-sign-compare -I${CMAKE_CURRENT_SOURCE_DIR} -I${CMAKE_CURRENT_SOURCE_DIR}/oboe)

set(CMAKE_EXECUTABLE_SUFFIX ".so")

add_executable(libcitrus
    main.cpp

    fs_android.cpp
    fs_android.h
    applets/software_keyboard.cpp
    applets/software_keyboard.h

    emu_window/emu_window.cpp
    emu_window/emu_window.h
    emu_window/backend_window.cpp
    emu_window/backend_window.h
    binder.h
    native.cpp
    native.h
    native_config.cpp
    android_settings.cpp
    game_metadata.cpp
    native_log.cpp
    android_config.cpp
    android_config.h
    android_input.cpp
    native_input.cpp

    sink/oboe_sink.cpp
    sink/oboe_sink.h
    android_protocol.h
)
target_compile_options(libcitrus PRIVATE -I${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(libcitrus PRIVATE audio_core common core input_common frontend_common Vulkan::Headers ffmpeg oboe preload)
target_link_libraries(libcitrus PRIVATE android camera2ndk EGL glad log mediandk binder_ndk)
if (ARCHITECTURE_arm64)
    target_link_libraries(libcitrus PRIVATE adrenotools)
endif()

set(CPACK_PACKAGE_EXECUTABLES ${CPACK_PACKAGE_EXECUTABLES} libcitrus)

add_library(citrus-android SHARED android_protocol.h android_jni.cpp)
target_link_libraries(citrus-android PRIVATE android binder_ndk)
